﻿<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
      <title>KCPServerNetworkChannel 类
 | Fantasy.Net API Reference </title>
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <meta name="title" content="KCPServerNetworkChannel 类
 | Fantasy.Net API Reference ">
      
      <link rel="icon" href="../favicon.ico">
      <link rel="stylesheet" href="../public/docfx.min.css">
      <link rel="stylesheet" href="../public/main.css">
      <meta name="docfx:navrel" content="../toc.html">
      <meta name="docfx:tocrel" content="toc.html">
      
      <meta name="docfx:rel" content="../">
      
      
      
  </head>

  <script type="module">
    import options from './../public/main.js'
    import { init } from './../public/docfx.min.js'
    init(options)
  </script>

  <script>
    const theme = localStorage.getItem('theme') || 'auto'
    document.documentElement.setAttribute('data-bs-theme', theme === 'auto' ? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') : theme)
  </script>

  <body class="tex2jax_ignore" data-layout="" data-yaml-mime="ManagedReference">
    <header class="bg-body border-bottom">
      <nav id="autocollapse" class="navbar navbar-expand-md" role="navigation">
        <div class="container-xxl flex-nowrap">
          <a class="navbar-brand" href="../index.html">
            <img id="logo" class="svg" src="../logo.svg" alt="Fantasy.Net">
            Fantasy.Net
          </a>
          <button class="btn btn-lg d-md-none border-0" type="button" data-bs-toggle="collapse" data-bs-target="#navpanel" aria-controls="navpanel" aria-expanded="false" aria-label="Toggle navigation">
            <i class="bi bi-three-dots"></i>
          </button>
          <div class="collapse navbar-collapse" id="navpanel">
            <div id="navbar">
              <form class="search" role="search" id="search">
                <i class="bi bi-search"></i>
                <input class="form-control" id="search-query" type="search" disabled="" placeholder="搜索" autocomplete="off" aria-label="Search">
              </form>
            </div>
          </div>
        </div>
      </nav>
    </header>

    <main class="container-xxl">
      <div class="toc-offcanvas">
        <div class="offcanvas-md offcanvas-start" tabindex="-1" id="tocOffcanvas" aria-labelledby="tocOffcanvasLabel">
          <div class="offcanvas-header">
            <h5 class="offcanvas-title" id="tocOffcanvasLabel">Table of Contents</h5>
            <button type="button" class="btn-close" data-bs-dismiss="offcanvas" data-bs-target="#tocOffcanvas" aria-label="Close"></button>
          </div>
          <div class="offcanvas-body">
            <nav class="toc" id="toc"></nav>
          </div>
        </div>
      </div>

      <div class="content">
        <div class="actionbar">
          <button class="btn btn-lg border-0 d-md-none" style="margin-top: -.65em; margin-left: -.8em" type="button" data-bs-toggle="offcanvas" data-bs-target="#tocOffcanvas" aria-controls="tocOffcanvas" aria-expanded="false" aria-label="Show table of contents">
            <i class="bi bi-list"></i>
          </button>

          <nav id="breadcrumb"></nav>
        </div>

        <article data-uid="Fantasy.KCPServerNetworkChannel">



  <h1 id="Fantasy_KCPServerNetworkChannel" data-uid="Fantasy.KCPServerNetworkChannel" class="text-break">
    KCPServerNetworkChannel 类
  
  </h1>

  <div class="facts text-secondary">
    <dl><dt>命名空间</dt><dd><a class="xref" href="Fantasy.html">Fantasy</a></dd></dl>
  <dl><dt>程序集</dt><dd>Fantasy.Net.dll</dd></dl>
  </div>

  <div class="markdown summary"><p>KCP 服务器网络通道类，负责管理基于 KCP 协议的网络通信。</p>
</div>
  <div class="markdown conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public sealed class KCPServerNetworkChannel : ANetworkChannel</code></pre>
  </div>




  <dl class="typelist inheritance">
    <dt>继承</dt>
    <dd>
      <div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
      <div><a class="xref" href="Fantasy.ANetworkChannel.html">ANetworkChannel</a></div>
      <div><span class="xref">KCPServerNetworkChannel</span></div>
    </dd>
  </dl>



  <dl class="typelist derived">
    <dt>继承成员</dt>
    <dd>
    <div>
      <a class="xref" href="Fantasy.ANetworkChannel.html#Fantasy_ANetworkChannel_Id">ANetworkChannel.Id</a>
    </div>
    <div>
      <a class="xref" href="Fantasy.ANetworkChannel.html#Fantasy_ANetworkChannel_Scene">ANetworkChannel.Scene</a>
    </div>
    <div>
      <a class="xref" href="Fantasy.ANetworkChannel.html#Fantasy_ANetworkChannel_NetworkId">ANetworkChannel.NetworkId</a>
    </div>
    <div>
      <a class="xref" href="Fantasy.ANetworkChannel.html#Fantasy_ANetworkChannel_IsDisposed">ANetworkChannel.IsDisposed</a>
    </div>
    <div>
      <a class="xref" href="Fantasy.ANetworkChannel.html#Fantasy_ANetworkChannel_RemoteEndPoint">ANetworkChannel.RemoteEndPoint</a>
    </div>
    <div>
      <a class="xref" href="Fantasy.ANetworkChannel.html#Fantasy_ANetworkChannel_PacketParser">ANetworkChannel.PacketParser</a>
    </div>
    <div>
      <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gettype">object.GetType()</a>
    </div>
    <div>
      <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.tostring">object.ToString()</a>
    </div>
    <div>
      <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)">object.Equals(object)</a>
    </div>
    <div>
      <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)">object.Equals(object, object)</a>
    </div>
    <div>
      <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.referenceequals">object.ReferenceEquals(object, object)</a>
    </div>
    <div>
      <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode">object.GetHashCode()</a>
    </div>
  </dd></dl>

  <dl class="typelist extensionMethods">
    <dt>扩展方法</dt>
    <dd>
  <div>
      <a class="xref" href="Fantasy.JsonHelper.html#Fantasy_JsonHelper_ToJson__1___0_">JsonHelper.ToJson&lt;T&gt;(T)</a>
  </div>
  </dd></dl>





  <h2 class="section" id="constructors">构造函数
</h2>


  <a id="Fantasy_KCPServerNetworkChannel__ctor_" data-uid="Fantasy.KCPServerNetworkChannel.#ctor*"></a>

  <h3 id="Fantasy_KCPServerNetworkChannel__ctor_Fantasy_Scene_System_UInt32_System_Int64_System_Net_EndPoint_System_Net_Sockets_Socket_System_UInt32_" data-uid="Fantasy.KCPServerNetworkChannel.#ctor(Fantasy.Scene,System.UInt32,System.Int64,System.Net.EndPoint,System.Net.Sockets.Socket,System.UInt32)">
  KCPServerNetworkChannel(Scene, uint, long, EndPoint, Socket, uint)
  
  </h3>

  <div class="markdown level1 summary"><p>构造函数，创建 KCP 服务器网络通道实例。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public KCPServerNetworkChannel(Scene scene, uint id, long networkId, EndPoint remoteEndPoint, Socket socket, uint createTime)</code></pre>
  </div>

  <h4 class="section">参数</h4>
  <dl class="parameters">
    <dt><code>scene</code> <a class="xref" href="Fantasy.Scene.html">Scene</a></dt>
    <dd><p>所属场景</p>
</dd>
    <dt><code>id</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.uint32">uint</a></dt>
    <dd><p>通道 ID</p>
</dd>
    <dt><code>networkId</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int64">long</a></dt>
    <dd><p>网络 ID</p>
</dd>
    <dt><code>remoteEndPoint</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.net.endpoint">EndPoint</a></dt>
    <dd><p>远程终端点</p>
</dd>
    <dt><code>socket</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.net.sockets.socket">Socket</a></dt>
    <dd><p>套接字</p>
</dd>
    <dt><code>createTime</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.uint32">uint</a></dt>
    <dd><p>创建时间</p>
</dd>
  </dl>












  <h2 class="section" id="fields">字段
</h2>



  <h3 id="Fantasy_KCPServerNetworkChannel_CreateTime" data-uid="Fantasy.KCPServerNetworkChannel.CreateTime">
  CreateTime
  
  </h3>

  <div class="markdown level1 summary"><p>连接创建时间（只读），用于记录连接建立的时间戳。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public readonly uint CreateTime</code></pre>
  </div>




  <h4 class="section">字段值</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.uint32">uint</a></dt>
    <dd></dd>
  </dl>









  <h2 class="section" id="properties">属性
</h2>


  <a id="Fantasy_KCPServerNetworkChannel_Kcp_" data-uid="Fantasy.KCPServerNetworkChannel.Kcp*"></a>

  <h3 id="Fantasy_KCPServerNetworkChannel_Kcp" data-uid="Fantasy.KCPServerNetworkChannel.Kcp">
  Kcp
  
  </h3>

  <div class="markdown level1 summary"><p>KCP协议实例，用于处理可靠的数据传输。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public Kcp Kcp { get; }</code></pre>
  </div>





  <h4 class="section">属性值</h4>
  <dl class="parameters">
    <dt><a class="xref" href="kcp2k.Kcp.html">Kcp</a></dt>
    <dd></dd>
  </dl>








  <h2 class="section" id="methods">方法
</h2>


  <a id="Fantasy_KCPServerNetworkChannel_Connect_" data-uid="Fantasy.KCPServerNetworkChannel.Connect*"></a>

  <h3 id="Fantasy_KCPServerNetworkChannel_Connect_kcp2k_Kcp_System_Action_System_UInt32_System_UInt32__System_Int32_Fantasy_NetworkTarget_Fantasy_ANetworkMessageScheduler_" data-uid="Fantasy.KCPServerNetworkChannel.Connect(kcp2k.Kcp,System.Action{System.UInt32,System.UInt32},System.Int32,Fantasy.NetworkTarget,Fantasy.ANetworkMessageScheduler)">
  Connect(Kcp, Action&lt;uint, uint&gt;, int, NetworkTarget, ANetworkMessageScheduler)
  
  </h3>

  <div class="markdown level1 summary"><p>连接到客户端，并设置 KCP 参数。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public void Connect(Kcp kcp, Action&lt;uint, uint&gt; addToUpdate, int maxSndWnd, NetworkTarget networkTarget, ANetworkMessageScheduler networkMessageScheduler)</code></pre>
  </div>

  <h4 class="section">参数</h4>
  <dl class="parameters">
    <dt><code>kcp</code> <a class="xref" href="kcp2k.Kcp.html">Kcp</a></dt>
    <dd><p>KCP 实例</p>
</dd>
    <dt><code>addToUpdate</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.action-2">Action</a>&lt;<a class="xref" href="https://learn.microsoft.com/dotnet/api/system.uint32">uint</a>, <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.uint32">uint</a>&gt;</dt>
    <dd><p>添加到更新的方法</p>
</dd>
    <dt><code>maxSndWnd</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></dt>
    <dd><p>最大发送窗口大小</p>
</dd>
    <dt><code>networkTarget</code> <a class="xref" href="Fantasy.NetworkTarget.html">NetworkTarget</a></dt>
    <dd><p>网络目标</p>
</dd>
    <dt><code>networkMessageScheduler</code> <a class="xref" href="Fantasy.ANetworkMessageScheduler.html">ANetworkMessageScheduler</a></dt>
    <dd><p>网络消息调度器</p>
</dd>
  </dl>












  <a id="Fantasy_KCPServerNetworkChannel_Dispose_" data-uid="Fantasy.KCPServerNetworkChannel.Dispose*"></a>

  <h3 id="Fantasy_KCPServerNetworkChannel_Dispose" data-uid="Fantasy.KCPServerNetworkChannel.Dispose">
  Dispose()
  
  </h3>

  <div class="markdown level1 summary"><p>释放资源并断开连接。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public override void Dispose()</code></pre>
  </div>













  <a id="Fantasy_KCPServerNetworkChannel_Output_" data-uid="Fantasy.KCPServerNetworkChannel.Output*"></a>

  <h3 id="Fantasy_KCPServerNetworkChannel_Output_System_Byte___System_Int32_" data-uid="Fantasy.KCPServerNetworkChannel.Output(System.Byte[],System.Int32)">
  Output(byte[], int)
  
  </h3>

  <div class="markdown level1 summary"><p>将数据发送到网络。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public void Output(byte[] bytes, int count)</code></pre>
  </div>

  <h4 class="section">参数</h4>
  <dl class="parameters">
    <dt><code>bytes</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.byte">byte</a>[]</dt>
    <dd><p>字节数组</p>
</dd>
    <dt><code>count</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></dt>
    <dd><p>发送的字节数</p>
</dd>
  </dl>












  <a id="Fantasy_KCPServerNetworkChannel_Receive_" data-uid="Fantasy.KCPServerNetworkChannel.Receive*"></a>

  <h3 id="Fantasy_KCPServerNetworkChannel_Receive" data-uid="Fantasy.KCPServerNetworkChannel.Receive">
  Receive()
  
  </h3>

  <div class="markdown level1 summary"><p>接收数据并进行处理。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public void Receive()</code></pre>
  </div>













  <a id="Fantasy_KCPServerNetworkChannel_Send_" data-uid="Fantasy.KCPServerNetworkChannel.Send*"></a>

  <h3 id="Fantasy_KCPServerNetworkChannel_Send_System_IO_MemoryStream_" data-uid="Fantasy.KCPServerNetworkChannel.Send(System.IO.MemoryStream)">
  Send(MemoryStream)
  
  </h3>

  <div class="markdown level1 summary"><p>发送数据到客户端。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public void Send(MemoryStream memoryStream)</code></pre>
  </div>

  <h4 class="section">参数</h4>
  <dl class="parameters">
    <dt><code>memoryStream</code> <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.memorystream">MemoryStream</a></dt>
    <dd><p>内存流</p>
</dd>
  </dl>












  <h2 class="section" id="events">事件
</h2>



  <h3 id="Fantasy_KCPServerNetworkChannel_OnDispose" data-uid="Fantasy.KCPServerNetworkChannel.OnDispose">
  OnDispose
  
  </h3>

  <div class="markdown level1 summary"><p>当网络通道被释放时触发的事件。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public override event Action OnDispose</code></pre>
  </div>






  <h4 class="section">事件类型</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.action">Action</a></dt>
    <dd></dd>
  </dl>








  <h3 id="Fantasy_KCPServerNetworkChannel_OnReceiveMemoryStream" data-uid="Fantasy.KCPServerNetworkChannel.OnReceiveMemoryStream">
  OnReceiveMemoryStream
  
  </h3>

  <div class="markdown level1 summary"><p>当接收到内存流数据包时触发的事件。</p>
</div>
  <div class="markdown level1 conceptual"></div>

  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public override event Action&lt;APackInfo&gt; OnReceiveMemoryStream</code></pre>
  </div>






  <h4 class="section">事件类型</h4>
  <dl class="parameters">
    <dt><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.action-1">Action</a>&lt;<a class="xref" href="Fantasy.APackInfo.html">APackInfo</a>&gt;</dt>
    <dd></dd>
  </dl>








</article>


        
      </div>

      <div class="affix">
        <nav id="affix"></nav>
      </div>
    </main>

    <div class="container-xxl search-results" id="search-results"></div>

    <footer class="border-top">
      <div class="container-xxl">
        <div class="flex-fill">
          <span>Made with <a href="https://dotnet.github.io/docfx">docfx</a></span>
        </div>
      </div>
    </footer>
  </body>
</html>